
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.common.dto.*;
import com.insigma.business.qrcode.common.entity.CommonAttachmentDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonAttachmentProviderConverter extends AbstractConverter<CommonAttachmentDTO, CommonAttachmentDO> {

    private final static CommonAttachmentProviderConverter commonAttachmentConverter = new CommonAttachmentProviderConverter();

    private CommonAttachmentProviderConverter(){}

    
    public static CommonAttachmentBSearcher convertRequestSO2Searcher(final CommonAttachmentSearchRequest request){
        final CommonAttachmentBSearcher commonAttachmentBSearcher = new CommonAttachmentBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonAttachmentBSearcher);
        return commonAttachmentBSearcher;
    }

    
    public static CommonAttachmentDO convertRequestUO2DO(final CommonAttachmentUpdateRequest commonAttachmentUpdateRequest) {
        final CommonAttachmentDO commonAttachmentDO = new CommonAttachmentDO();
        BeanUtils.copyProperties(commonAttachmentUpdateRequest,commonAttachmentDO);
        
        return commonAttachmentDO;
    }

    
    public static CommonAttachmentDO convertRequestIO2DO(final CommonAttachmentInsertRequest commonAttachmentInsertRequest) {
        final CommonAttachmentDO commonAttachmentDO = new CommonAttachmentDO();
        BeanUtils.copyProperties(commonAttachmentInsertRequest,commonAttachmentDO);
        return commonAttachmentDO;
    }

    
    public static List<CommonAttachmentDTO> convertResponseDOList2DTOList(final List<CommonAttachmentDO> commonAttachmentDOList){
        return commonAttachmentConverter.convertGenericResponseDOList2DTOList(commonAttachmentDOList);
    }

    
    public static CommonAttachmentDTO convertResponseDO2DTO(final CommonAttachmentDO commonAttachmentDO){
        return commonAttachmentConverter.convertGenericResponseDO2DTO(commonAttachmentDO);
    }

    
    @Override
    protected CommonAttachmentDTO doConvertResponseDO2DTO(CommonAttachmentDO commonAttachmentDO) {
        final CommonAttachmentDTO commonAttachmentDTO = new CommonAttachmentDTO();
        try {
            BeanUtils.copyProperties(commonAttachmentDO, commonAttachmentDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonAttachmentDTO;
    }

}
